<script setup>
import { reactive } from "vue";
import { ElMessage } from "element-plus"; // 导入 Element Plus 的警告框组件
import { reset } from '@/api/reset'

import router from '@/router'

const form = reactive({
  id: ''
})

// 重置密码的东西
function resetPassword() {
  if(!form.id) {
    ElMessage.warning('请输入要重置的账号');
    return;
  }
  // 调用并跳转
  // console.log('111')
  reset(form.id, router.push('/login'))
}
</script>

<template>
  <div class="reset">
    <h1 class="resetTitle">重置密码</h1>
    <h5 class="resetTips">请输入你要重置的账号，重置后恢复默认密码</h5>

    <!-- 输入框 -->
    <div class="resetInput">
      <el-form :model="form">
        <el-form-item prop="username">
          <el-input v-model="form.id" placeholder="请输入你要重置的账号">

          </el-input>
        </el-form-item>
      </el-form>
    </div>

    <!-- 按钮 -->
    <div style="margin-top: 36px">
      <el-button @click="resetPassword" style="width: 24vw;margin-top: 36px" type="success" plain>重置密码</el-button>
      <br>
      <el-button @click="router.push('/login')" style="width: 24vw;margin-top: 36px" type="primary" plain>返回登录</el-button>
    </div>
  </div>
</template>

<style>
.reset{
  text-align: center;
  margin: 1vw 1vw 0 1vw;
}

.resetTitle{
  font-size: 38px;
  font-weight: 500;
}

.resetTips{
  margin-top: 18px;
  font-size: 12px;
  font-weight: 500;
  color: white;
}

.resetInput{
  width: 50vw;
  margin: 5vw auto;
}
</style>